import { getList, setFormData, xgFormData, delData } from "@/api/msbd.js"

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


export default {
    state: {
        tableList: [],
        classifyList: [],
        currentpage: 1,
        pagesize: 5,
        total: 0
    },
    mutations: {
        SET_DATALIST(state, v) {
            state.classifyList = v.classify
            state.tableList = v.data
            state.total = v.total[0].total
        },
        SET_CURRENTPAGE(state, v) {
            state.currentpage = v
        },
        SET_PAGESIZE(state, v) {
            state.pagesize = v
        },

    },
    actions: {
        async  getMsbdList({ commit, state }, v) {
            let r = await getList({ currentPage: state.currentpage-1, pageSize: state.pagesize, keyword: v })
            commit("SET_DATALIST", r)

        },
        async getAddList({ commit }, v) {
            await setFormData(v)
        },
        async xgFormList({ commit }, v) {
            await xgFormData(v)
        },
        async delMsbdList({ commit }, v) {
            await delData(v)
        }
    },
    namespaced: true
}
